package com.dlg.commons.viewmodel;

/**
 * Created by zhangjinxia on 2017/8/8.
 */
public class ResponseViewModel<T> {
    private int code=0;
    private String msg="成功";
    private T data;

    public ResponseViewModel(){
        super();
    }

    public ResponseViewModel(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static ResponseViewModel error(String msg){
        return new ResponseViewModel(1,msg);
    }

    public static ResponseViewModel success(){
        return new ResponseViewModel(0,"成功");
    }

    public ResponseViewModel<T> setData(T data) {
        this.data = data;
        return this;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

}
